<?php
    require_once 'public/includes/functions.php';
    require_once 'models/container.php';
    
    class ItemController extends functions {
        
        var $container =null;
        var $breakPage = null;
        
        function __construct(){
            $this->container = new Container_Model();            
        }
        
        /**
         * Load thong tin theo cataloge
         * @return String
         */
        function listItemContainer($currentPage){
            $row = 5;
            $list = array();
            if(empty($currentPage)|| $currentPage==1) $currentPage = 0; 
            $total = mysql_num_rows($this->container->ExecuteTable("container"));
            $start = $currentPage*$row;
            if(isset($_GET['id'])){
                $id = $_GET['id'];
                $sql = "select * from container where cat_id='".$id."' LIMIT $start,{$row}";
                $res = $this->container->ExecuteSQL($sql);
                while($rs=mysql_fetch_array($res)){
    	            $idbaiviet=$rs['ID'];
        			$name=$rs['name'];
        			$gioithieu=$rs['gioithieu'];
        			$anh=$rs['anh'];
        			//echo $anh; 
    				$list[] = "<div class='noidung'>
    					           <div class='part'>
    				                    <a href='./?rt=page&?id=$idbaiviet'>
                                            <img src='upload/images/$anh' class='hinhbaiviet' width='178' height ='185'/>
                                        </a>
    				                    <img src='public/images/logobaiviet.png' class ='logobaiviet'/>
                                        <a href='./?rt=page&id=$idbaiviet'><h3 class='tieude'> $name </h3>
                                        </a>
    				                    <p>  $gioithieu  </p>
    				                    <a href='./?rt=page&id=$idbaiviet' class='tieptuc' title='Đọc tiếp'> >>> 
                                        </a>								
    				                </div>			            					
    			             </div>";
                }
            
        //			<!-- end div nội dung-->	
            }
            
            $this->breakPage = $this->divPage($total,$currentPage,3,$row,'','');
            
            return $list;
        }
        
        public function indexAtion(){
            
        }
    }
    
    // thuc thi class
    $item = new ItemController();
    $item->show('items');
?>